package com.yiban.demo.Station.Entity;

import com.yiban.demo.Order.Entity.OrderPO;
import com.yiban.demo.Order.Entity.OrderVO;
import lombok.Data;
import lombok.Getter;

import javax.validation.Valid;
import java.util.Optional;

@Data
public class StationOrderMessage {


    private String desc;
    @Valid
    private OrderVO order;


    public StationOrderMessage() {

    }

    public StationOrderMessage(StationOrderMessageClass messageClass, OrderVO order) {
        this.desc = messageClass.getDesc();
        this.order = order;
    }
    public static StationOrderMessage generate(StationOrderMessageClass SOMClass,OrderVO order){
        return new StationOrderMessage(SOMClass, order);
    }


    @Getter
    public enum  StationOrderMessageClass {
        RECEIVE("接收订单"),
        DELIVERY("运送订单"),
        ADD("添加新订单"),
        END("订单结束"),
        IDLE("心跳");
        private String desc;
        private StationOrderMessageClass(String desc) {
                this.desc = desc;
        }
        public static Optional<StationOrderMessageClass> getInstance(String s){
            for (StationOrderMessageClass value : StationOrderMessageClass.values()) {
                if (value.name().equals(s)) {
                    return Optional.of(value);
                }
            }
        return Optional.empty();
        }


    }
}

